<?php
namespace app\admin\module;

use app\common\model\Goods;

class GoodsModule{

    public static function page($pageSize = 10){
        return Goods::where([])->order('id','desc')->paginate($pageSize);
    }

    public static function create($data){
        $data['images'] = json_encode($data['images']);
        $data['createtime'] = time();
        Goods::create($data);
    }

    public static function update($data){
        $data['images'] = json_encode($data['images']);
        $data['updatetime'] = time();
        Goods::update($data,['id'=>$data['id']]);
    }

    //删除商品不会影响订单，订单的商品是当时商品的信息，属于过去的信息
    public static function del($id){
        Goods::destroy($id);
    }
}
